<template>
  <div>
    <van-search v-model="value" shape="round" placeholder="请输入搜索关键词" />
    <h1>系统消息</h1>
    <XiTongxiaoxi
      v-for="(item) in xitong"
      :key="item.id"
      :ddata="item"
    ></XiTongxiaoxi>
    <h1>好友消息</h1>
    <XiTongxiaoxi
      v-for="(item) in haoyou"
      :key="item.id"
      :ddata="item"
    ></XiTongxiaoxi>
  </div>
</template>

<script>
// import HaoYouxiaoxi from "./QIangGuotong/HaoYouxiaoxi.vue";
import XiTongxiaoxi from "./QIangGuotong/XiTongxiaoxi.vue";
import axios from "axios";
export default {
  name: "QiangGuotong",
  data() {
    return {
      value: "",
      xitong: [],
      haoyou: [],
      // 全部聊天消息
      quanbuliaotianxiaoxi: [],
    };
  },
  async mounted() {
    // 获取聊天消息
    await axios
      .post(
        "http://localhost:8080/friend/user",
        { woUid: localStorage.getItem('userxx') },
        {
          headers: {
            "Content-Type": "application/x-www-form-urlencoded", // 或者 'multipart/form-data'
          },
        }
      )
      .then((res) => {
        console.log(res.data.data);
        this.$store.state.ltjl=res.data.data
        this.quanbuliaotianxiaoxi = this.$store.state.ltjl;
      });

    this.quanbuliaotianxiaoxi.forEach((item) => {
      if (item.uid.slice(0, 2) == "gf") {
        this.xitong.push(item);
      } else {
        this.haoyou.push(item);
      }
    });
  },
  components: {
    XiTongxiaoxi,
    // HaoYouxiaoxi,
  },
};
</script>

<style>
</style>